<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Data Tables</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="../css/bootstrap.min.css">
</head>
<body class="hold-transition skin-blue sidebar-mini">

<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div id="app" class="box">
                    <div class="box-header">
                        <button @click="openAddWindow()" type="button" class="btn btn-success">添加</button>
                    </div>
                    <div class="box-body">
                        <!--数据表格-->
                        <table id="data_table" class="table table-bordered table-hover">
                            <thead>
                            <tr>
                                <th class="sorting_asc">ID</th>
                                <th class="sorting_desc">账号名</th>
                                <th class="sorting">余额</th>
                                <th class="text-center">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <!--循环次tr,插值表达式赋值 -->
                            <tr align="center" v-for="account in pageInfo.list" style="font-size: 20px">
                                <td>{{account.id}}</td>
                                <td>{{account.name}}</td>
                                <td>{{account.money}}</td>
                                <td>
                                    <button type="button" class="btn btn-info" @click="openUpdateWindow(account.id)">修改</button>
                                    <button type="button" class="btn btn-danger" @click="deleteAccount(account.id)">删除</button>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <!--修改 模块-->
                    <div id="update_modal" class="modal fade" role="dialog">
                        <div class="modal-dialog modal-lg">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title">修改--用户信息</h4>
                                </div>
                                <div class="modal-body">
                                    <input type="hidden" class="form-control">
                                    <div class="box-body">
                                        <div class="box-body">
                                            <div class="form-group">
                                                <label for="inputEmail3" class="col-sm-2 control-label">账户名</label>
                                                <div class="col-sm-10">
                                                    <input type="text" class="form-control" placeholder="name" v-model="accountInfo.name">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label for="inputPassword3" class="col-sm-2 control-label" >余额</label>

                                                <div class="col-sm-10">
                                                    <input type="text" class="form-control" placeholder="money" v-model="accountInfo.money">
                                                </div>
                                            </div>

                                        </div>
                                        <div class="box-footer">
                                            <button type="button" class="btn btn-outline" data-dismiss="modal">关闭
                                            </button>
                                            <button @click="updateAccount()"  type="button" class="btn btn-outline" data-dismiss="modal">修改
                                            </button>
                                        </div>
                                    </div>

                                </div>
                            </div>
                            <!-- /.modal-content -->
                        </div>

                        <!-- /.modal-dialog -->
                    </div>
                    <!--添加  模块-->
                    <div id="add_modal" class="modal fade" role="dialog">
                        <div class="modal-dialog modal-lg">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title">添加--用户信息</h4>
                                </div>
                                <div class="modal-body">

                                    <div class="box-body">
                                        <form class="form-horizontal">
                                            <div class="box-body">
                                                <div class="form-group">
                                                    <label for="inputEmail3" class="col-sm-2 control-label">账户名</label>

                                                    <div class="col-sm-10">
                                                        <!--Vue的功能，数据的双向绑定-->
                                                        <input type="text" class="form-control" id="inputEmail3"
                                                               placeholder="name" v-model="accountInfo.name">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="inputPassword3"
                                                           class="col-sm-2 control-label">余额</label>

                                                    <div class="col-sm-10">
                                                        <input type="text" class="form-control" id="inputPassword3"
                                                               placeholder="money" v-model="accountInfo.money">
                                                    </div>
                                                </div>

                                            </div>
                                            <!-- /.box-body -->
                                            <div class="box-footer">
                                                <button type="button" class="btn btn-outline" data-dismiss="modal">关闭
                                                </button>
                                                <button @click="insertAccount()" type="button" class="btn btn-outline"  data-dismiss="modal">添加
                                                </button>
                                            </div>
                                            <!-- /.box-footer -->
                                        </form>
                                    </div>

                                </div>
                            </div>
                            <!-- /.modal-content -->
                        </div>
                        <!-- /.modal-dialog -->
                    </div>
                    <!-- /.box-body -->

                    <div style="width: 380px; margin: 0 auto; margin-top: 50px;">
                        <ul class="pagination" style="text-align: center; margin-top: 10px;">

                            <template v-if="pageInfo.pageNum == 1">
                                <li class="disabled">
                                    <a href="javascript:;" aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>
                            </template>
                            <template v-if="pageInfo.pageNum != 1">
                                <li>
                                    <a href="javascript:;" aria-label="Previous" @click="queryAccountByPage(pageInfo.pageNum-1)">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>
                            </template>

                            <template v-for="i in pageInfo.pages">
                                <template v-if="pageInfo.pageNum == i">
                                <li class="active"><a href="javascript:;" >{{i}}</a></li>
                                </template>

                                <template v-if="pageInfo.pageNum != i">
                                    <li><a href="javascript:;" @click="queryAccountByPage(i)">{{i}}</a></li>
                                </template>
                            </template>


                            <template v-if="pageInfo.pageNum == pageInfo.pages">
                                <li class="disabled"><a href="javascript:;" aria-label="Next" >
                                    <span aria-hidden="true">&raquo;</span>
                                </a></li>
                            </template>
                            <template v-if="pageInfo.pageNum != pageInfo.pages">
                            <li><a href="javascript:;" aria-label="Next" @click="queryAccountByPage(pageInfo.pageNum + 1)">
                                <span aria-hidden="true">&raquo;</span>
                            </a></li>
                            </template>
                        </ul>
                    </div>


                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>
</div>
</body>
<script src="../js/jquery-1.12.4.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script src="../js/vue.min.js"></script>
<script src="../js/account.js"></script>
</html>
